package bdqn.com.cui.serviet;

import bdqn.com.cui.pojo.Productcates;
import bdqn.com.cui.service.Productcatesseervice;
import bdqn.com.cui.service.impl.Productcatesserviceimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "commodityServiet",urlPatterns = "/productcates")
public class productcateserviet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html; charset=UTF-8");//设置页面属性为  UTF-8
        req.setCharacterEncoding("UTF-8");
        String opr=req.getParameter("opr");
        Productcatesseervice productcatesseervice=new Productcatesserviceimpl();

        if (opr.equals("select1")){
            List<Productcates> productcates = productcatesseervice.fenleiselect1();
            req.getSession().setAttribute("productcates",productcates);
            resp.sendRedirect("shangpin_add.jsp");
        }else if (opr.equals("select2")){
            List<Productcates> productcates = productcatesseervice.fenleiselect2();
            req.getSession().setAttribute("productcates",productcates);
            resp.sendRedirect("shangpin_add.jsp");
        }else if (opr.equals("select3")){
            List<Productcates> productcates = productcatesseervice.fenleiselect3();
            req.getSession().setAttribute("productcates",productcates);
            resp.sendRedirect("shangpin_add.jsp");
        }


    }
}
